package com.hongxin.nw.netty.config;

import com.hongxin.nw.netty.handle.CustomDecoder;
import com.hongxin.nw.netty.handle.InitHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 管道执行顺序:  先read后write, read正序,,write反序
 * @author guoxiaolin
 * @date 创建于 上午9:14 2019/5/10
 */
@Slf4j
@Component
public class ServerChannelInitializer extends ChannelInitializer<SocketChannel>{

    @Override
    protected void initChannel(SocketChannel socketChannel) {
        socketChannel.pipeline().addLast("pack", new CustomDecoder(2048,2,4,0,0,false));//判断数据接收是否完整
        socketChannel.pipeline().addLast("init", new InitHandler());//处理业务,包括登录
    }


}